package ${commonPackage};

import static org.springframework.util.Assert.notNull;

import org.apache.ibatis.session.SqlSession;
import org.springframework.dao.support.DaoSupport;


/**
 * 实现DaoSupport
 *
 *
 * @author ${author}
 * @version ${currentDate} ${author}
 */
public class DynamicSqlSessionDaoSupport extends DaoSupport {
    private SqlSession sqlSession;


    /**
     * 设置sqlSessionTemplate
     *
     * @param sqlSessionTemplate sql上下文模版
     */
    public void setSqlSessionTemplate(SqlSession sqlSessionTemplate) {
        this.sqlSession = sqlSessionTemplate;

    }


    /**
     * Users should use this method to get a SqlSession to call its statement
     * methods This is SqlSession is managed by spring. Users should not
     * commit/rollback/close it because it will be automatically done.
     * 
     * @return Spring managed thread safe SqlSession
     */
    public SqlSession getSqlSession() {
        return this.sqlSession;
    }


    /**
     * {@inheritDoc}
     */
    protected void checkDaoConfig() {
        notNull(this.sqlSession, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required");
    }

}